package com.spider.silence.job;

import com.spider.silence.downloader.WyzxDownloader;
import com.spider.silence.pool.WyzxDownloaderPool;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.StatefulJob;

import java.util.List;
import java.util.Map;

/**
 * @author Administrator
 * @description 描述
 * @time 2017/4/19 0019
 */
public class WyzxJob implements StatefulJob {

    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        WyzxDownloaderPool pool = null;
        WyzxDownloader downloader = null;

        try{
            pool = WyzxDownloaderPool.getInstance();
            downloader = pool.fetchDownLoader(1000);
            List<Map<String,Object>> urlList = downloader.getUrlList();
            //生成任务队列
            downloader.generateTask(urlList);
        }catch(Exception e){
            e.printStackTrace();
        }finally {
            if(downloader != null){
                pool.releaseDownLoader(downloader);
            }
        }
    }
}
